require 'payler_api/response'
require 'payler_api/request'

module PaylerAPI
  AvailableMethods = [:pay, :block, :charge, :refund, :retrieve, :get_status, :send_3ds]

  def self.method_missing(method, *arguments, &block)
    return super unless AvailableMethods.include? method

    PaylerAPI::Request.new(method, *arguments).process
  end

  # self.configure method
  #   for setup :access_key
  class << self
    attr_accessor :configuration

    def configuration
      @configuration ||= Configuration.new
    end

    def configure
      yield(configuration)
    end
  end

  class Configuration
    attr_accessor :access_key, :host, :password

    def initialize
      @access_key, @host, @password = ['']*3
    end
  end
end
